package org.sasha.roulette.actionbar;

import com.github.peholmst.mvp4vaadin.AbstractView;
import com.google.inject.Inject;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.ComponentContainer;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.NativeButton;

@SuppressWarnings("serial")
public class FastSpinCreationViewImpl extends AbstractView<FastSpinCreationView, FastSpinCreationPresenter> implements FastSpinCreationView {

    private final HorizontalLayout root = new HorizontalLayout();  
    
    @Inject
    public FastSpinCreationViewImpl(final FastSpinCreationPresenter presenter) {
        super(false);
        setPresenter(presenter);
        presenter.setView(this);
        root.setWidth("100%");
        for (int i = 0; i < 37; ++i) {
            final Integer number = i;
            final Button b = new NativeButton(String.valueOf(i), new ClickListener() {
                @Override
                public void buttonClick(ClickEvent event) {
                    getPresenter().addSpin(number);
                }
            });
            b.setWidth("100%");
            root.addComponent(b);
        }
        init();
    }
    
    @Override
    public ComponentContainer getViewComponent() {
        return root;
    }
}
